<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>QUnit for TBSCertificate and Certificate class constructor test in 'asn1x509.js'</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>

<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/base64.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/rsasign-1.2.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/asn1x509-1.0.js"></script>
<script src="../src/x509-1.1.js"></script>
<script src="../src/keyutil-1.0.js"></script>

<script type="text/javascript">
<!--
$(document).ready(function(){

var githubPEM = (function() {/*-----BEGIN CERTIFICATE-----
MIIF4DCCBMigAwIBAgIQDACTENIG2+M3VTWAEY3chzANBgkqhkiG9w0BAQsFADB1
MQswCQYDVQQG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Gh1Yi5jb20wDgYDVR0PAQH/BAQDAgWgMB0G
A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjB1BgNVHR8EbjBsMDSgMqAwhi5o
dHRwOi8vY3JsMy5kaWdpY2VydC5jb20vc2hhMi1ldi1zZXJ2ZXItZzEuY3JsMDSg
MqAwhi5odHRwOi8vY3JsNC5kaWdpY2VydC5jb20vc2hhMi1ldi1zZXJ2ZXItZzEu
Y3JsMEIGA1UdIAQ7MDkwNwYJYIZIAYb9bAIBMCowKAYIKwYBBQUHAgEWHGh0dHBz
Oi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwgYgGCCsGAQUFBwEBBHwwejAkBggrBgEF
BQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMFIGCCsGAQUFBzAChkZodHRw
Oi8vY2FjZXJ0cy5kaWdpY2VydC5jb20vRGlnaUNlcnRTSEEyRXh0ZW5kZWRWYWxp
ZGF0aW9uU2VydmVyQ0EuY3J0MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQELBQAD
ggEBAG/nbcuC8++QhwnXDxUiLIz+06scipbbXRJd0XjAMbD/RciJ9wiYUhcfTEsg
ZGpt21DXEL5+q/4vgNipSlhBaYFyGQiDm5IQTmIte0ZwQ26jUxMf4pOmI1v3kj43
FHU7uUskQS6lPUgND5nqHkKXxv6V2qtHmssrA9YNQMEK93ga2rWDpK21mUkgLviT
PB5sPdE7IzprOCp+Ynpf3RcFddAkXb6NqJoQRPrStMrv19C1dqUmJRwIQdhkkqev
ff6IQDlhC8BIMKmCNK33cEYDfDWROtW7JNgBvBTwww8jO1gyug8SbGZ6bZ3k8OV8
XX4C2NesiZcLYbc2n7B9O+63M2k=
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var githubHex = pemtohex(githubPEM);

// _test/0cert_rsa/z6.pub.p8.pem
var z6PUB = (function() {/*
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu2TRqUOXPzaxUkmrRWoT
bd8K+KFDucLErV41lNtqwhMHGnOOEWywNg4VORpFRNP8Z3rIwfqWtpHjCuO97r/M
5tKi1lerD+2Y46eBHqFMtf8C4xeySf4cdfvmjRToMq8q3SOAIKJ8PtUWUdtIurMU
aA/bYzHsZq/piJoZw0jC1Xx3bZk7SiMSGi7TljrVdcPzgPMkE//D+zDLclgAknAN
cJqHt/CI2Z89R0IaEHAsJsqrN34h4jcL1od4Cc2vXfpyQkolobfomTkIzKZ9V34l
I8GvLSOtZNdbq4gERm1zxnkHZ9j9kWsDZiiB+eCY2XokBIt09DUFgam4oTv3QkWO
twIDAQAB
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// _test/0cert_rsa/z6.prv.p5p.pem
var z6PRV = (function() {/*
-----BEGIN RSA PRIVATE KEY-----
MIIEpgIBAAKCAQEAu2TRqUOXPzaxUkmrRWoTbd8K+KFDucLErV41lNtqwhMHGnOO
EWywNg4VORpFRNP8Z3rIwfqWtpHjCuO97r/M5tKi1lerD+2Y46eBHqFMtf8C4xey
Sf4cdfvmjRToMq8q3SOAIKJ8PtUWUdtIurMUaA/bYzHsZq/piJoZw0jC1Xx3bZk7
SiMSGi7TljrVdcPzgPMkE//D+zDLclgAknANcJqHt/CI2Z89R0IaEHAsJsqrN34h
4jcL1od4Cc2vXfpyQkolobfomTkIzKZ9V34lI8GvLSOtZNdbq4gERm1zxnkHZ9j9
kWsDZiiB+eCY2XokBIt09DUFgam4oTv3QkWOtwIDAQABAoIBAQChXLpRR3uIml7s
nbUWi7X5STOYTr0Ty0wygUogSSRPw7S9KT3vcSj3Ev9hcWauUuAodwlCR7bZtRvN
d7hISu504HIJoeoSSCT7+3Pq3ThCCzoANJp4rpDxY5zuZU9gvYdqbrRY5bGZJUIX
8HxbD/OFfAoNC6Ml9VpiH1gJ2bCzxQWXCtvcoVHz0s50UXhp0omdo5RR+Jiwu0F5
tan3+m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cert_rsa/z6.jsrsa.pem
var z6CertPEM = (function() {/*
-----BEGIN CERTIFICATE-----
MIICqTCCAZGgAwIBAgICEjQwDQYJKoZIhvcNAQELBQAwEDEOMAwGA1UECgwFUm9v
dDEwHhcNMTkxMjMxMjM1OTU5WhcNMjExMjMxMjM1OTU5WjAOMQwwCgYDVQQKDANF
RTEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7ZNGpQ5c/NrFSSatF
ahNt3wr4oUO5wsStXjWU22rCEwcac44RbLA2DhU5GkVE0/xnesjB+pa2keMK473u
v8zm0qLWV6sP7Zjjp4EeoUy1/wLjF7JJ/hx1++aNFOgyryrdI4Agonw+1RZR20i6
sxRoD9tjMexmr+mImhnDSMLVfHdtmTtKIxIaLtOWOtV1w/OA8yQT/8P7MMtyWACS
cA1wmoe38IjZnz1HQhoQcCwmyqs3fiHiNwvWh3gJza9d+nJCSiWht+iZOQjMpn1X
fiUjwa8tI61k11uriARGbXPGeQdn2P2RawNmKIH54JjZeiQEi3T0NQWBqbihO/dC
RY63AgMBAAGjDzANMAsGA1UdDwQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAf71c
T4/OPXp/ontc3P9NLMBlAK8NIrYPrFJa7XXn62eVLqlxFx9L4uFFKCKesSQJIXYG
avH5sPOVedYc9UJi9oMpXvarJ2byKbVPNc9aX4g7hCSSrU20lV1w+uc+EpxzKrdr
LxRGvWvaQGX5UOPT8xF//DdoMa4C2RWo9GUF22o1q4KEJhCgVCpzM/mmSk43hii6
XavgmNXY6m5jScdFXVvguBNLK+MdulO1trdJlVS9E8DJnJ9dqGl1Ru4vba+89TFs
MdQ006Ap8agYDZhg2wjOnIDbVcRAiYg9LTaFhECf98i5D3paJwcdrSOwO9SvuOFz
BrAkayJpcFpK6crk+g==
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var z6CertHex = pemtohex(z6CertPEM);

var z6PARAM = {
serial:{hex:"1234"},
sigalg:"SHA256withRSA",
issuer: {str: "/O=Root1"},
notbefore: "191231235959Z",
notafter: "211231235959Z",
subject: {str: "/O=EE1"},
sbjpubkey: z6PUB,
ext:[{extname:"keyUsage",names:["digitalSignature"]}],
cakey: z6PRV};

var githubPARAM = 
{version:3,
 serial:{hex:"0c009310d206dbe337553580118ddc87"},
 sigalg:"SHA256withRSA",
 issuer: {
   array: [[{ds:'prn',type:'C',value:'US'}],
           [{ds:'prn',type:'O',value:'DigiCert Inc'}],
           [{ds:'prn',type:'OU',value:'www.digicert.com'}],
           [{ds:'prn',type:'CN',value:'DigiCert SHA2 Extended Validation Server CA'}]],
   str: "/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA"
 },
 notbefore:"140408000000Z",
 notafter:"160412120000Z",
 subject: {
   array: [[{ds:'utf8',type:'businessCategory',value:'Private Organization'}],
           [{ds:'prn',type:'jurisdictionOfIncorporationC',value:'US'}],
           [{ds:'prn',type:'jurisdictionOfIncorporationSP',value:'Delaware'}],
           [{ds:'prn',type:'serialNumber',value:'5157550'}],
           [{ds:'prn',type:'STREET',value:'548 4th Street'}],
           [{ds:'prn',type:'postalCode',value:'94107'}],
           [{ds:'prn',type:'C',value:'US'}],
           [{ds:'prn',type:'ST',value:'California'}],
           [{ds:'prn',type:'L',value:'San Francisco'}],
           [{ds:'prn',type:'O',value:'GitHub, Inc.'}],
           [{ds:'prn',type:'CN',value:'github.com'}]
          ],
   str: "/businessCategory=Private Organization/jurisdictionOfIncorporationC=US/jurisdictionOfIncorporationSP=Delaware/serialNumber=5157550/STREET=548 4th Street/postalCode=94107/C=US/ST=California/L=San Francisco/O=GitHub, Inc./CN=github.com"
 },
 sbjpubkey:"-----BEGIN PUBLIC KEY-----\r\n"+
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsdTcPK/9807twWet5ssi\r\n"+
"6Lfiqyjy99xicAjRDK/WFmohsDZLFw02YwSuv+ogUZVlZvK/uU2kDCnr9RWx6DWz\r\n"+
"cBCU1RtZtCYP1oNXWZ3hfAnd4BPKTW9Dm83PhzoVp4XdZoPtkwz+K204HHmIkM+t\r\n"+
"WBgtUdHCo/JHjG84Cbm470yTC8uDlIfq4KO12Xubaw9D+crugA0op3bxJfTBNTz2\r\n"+
"dK3eajOCe9z9S3anwu7yar+pJKZf5y58DtvDdHP6fsbYz2DrNlYhtsGKuCSCTXgk\r\n"+
"uukdoYqnh75mJWm/vjtybk/g5IUlCLGRibjWdGV2myxPYh+h+jq+nCS/n8qwxcBn\r\n"+
"jQIDAQAB\r\n"+
"-----END PUBLIC KEY-----\r\n",
 ext:[{
   extname:"authorityKeyIdentifier",
   kid:{hex:"3dd350a5d6a0adeef34a600a65d321d4f8f8d60f"}
 },{
   extname:"subjectKeyIdentifier",
   kid:{hex:"6a43907d3b98147252953aaa280a43f8517ed3a6"}
 },{
   extname:"subjectAltName",
   array:[{dns:"github.com"},{dns:"www.github.com"}]
 },{
   extname:"keyUsage", critical:true,
   names:["digitalSignature","keyEncipherment"]
 },{
   extname:"extKeyUsage",
   array:["serverAuth","clientAuth"]
 },{
   extname:"cRLDistributionPoints",
   array:[{dpname:{full:[{uri:"http://crl3.digicert.com/sha2-ev-server-g1.crl"}]}},
          {dpname:{full:[{uri:"http://crl4.digicert.com/sha2-ev-server-g1.crl"}]}}]
 },{
   extname:"certificatePolicies",
   array:[{policyoid:"2.16.840.1.114412.2.1",
           array:[{cps:"https://www.digicert.com/CPS"}]}]
 },{
   extname:"authorityInfoAccess",
   array:[{ocsp:"http://ocsp.digicert.com"},
          {caissuer:"http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt"}]
 },{
   extname:"basicConstraints",
   critical:true
 }],
 sighex:"6fe76dcb82f3ef908709d70f15222c8cfed3ab1c8a96db5d125dd178c031b0ff45c889f7089852171f4c4b20646a6ddb50d710be7eabfe2f80d8a94a58416981721908839b92104e622d7b4670436ea353131fe293a6235bf7923e3714753bb94b24412ea53d480d0f99ea1e4297c6fe95daab479acb2b03d60d40c10af7781adab583a4adb59949202ef8933c1e6c3dd13b233a6b382a7e627a5fdd170575d0245dbe8da89a1044fad2b4caefd7d0b576a526251c0841d86492a7af7dfe884039610bc04830a98234adf77046037c35913ad5bb24d801bc14f0c30f233b5832ba0f126c667a6d9de4f0e57c5d7e02d8d7ac89970b61b7369fb07d3beeb73369"
};

test("TBSCertificate test", function() {
var tbsc = new KJUR.asn1.x509.TBSCertificate(githubPARAM);
equal(tbsc.getEncodedHex(),
"308204c8a00302010202100c009310d206dbe337553580118ddc87300d06092a864886f70d01010b05003075310b300906035504061302555331153013060355040a130c446967694365727420496e6331193017060355040b13107777772e64696769636572742e636f6d313430320603550403132b4469676943657274205348413220457874656e6465642056616c69646174696f6e20536572766572204341301e170d3134303430383030303030305a170d3136303431323132303030305a3081f0311d301b060355040f0c1450726976617465204f7267616e697a6174696f6e31133011060b2b0601040182373c0201031302555331193017060b2b0601040182373c020102130844656c61776172653110300e0603550405130735313537353530311730150603550409130e3534382034746820537472656574310e300c060355041113053934313037310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d53616e204672616e636973636f31153013060355040a130c4769744875622c20496e632e311330110603550403130a6769746875622e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100b1d4dc3caffdf34eedc167ade6cb22e8b7e2ab28f2f7dc627008d10cafd6166a21b0364b170d366304aebfea2051956566f2bfb94da40c29ebf515b1e835b3701094d51b59b4260fd68357599de17c09dde013ca4d6f439bcdcf873a15a785dd6683ed930cfe2b6d381c798890cfad58182d51d1c2a3f2478c6f3809b9b8ef4c930bcb839487eae0a3b5d97b9b6b0f43f9caee800d28a776f125f4c1353cf674adde6a33827bdcfd4b76a7c2eef26abfa924a65fe72e7c0edbc37473fa7ec6d8cf60eb365621b6c18ab824824d7824bae91da18aa787be662569bfbe3b726e4fe0e4852508b19189b8d67465769b2c4f621fa1fa3abe9c24bf9fcab0c5c0678d0203010001a38201ee308201ea301f0603551d230418301680143dd350a5d6a0adeef34a600a65d321d4f8f8d60f301d0603551d0e041604146a43907d3b98147252953aaa280a43f8517ed3a630250603551d11041e301c820a6769746875622e636f6d820e7777772e6769746875622e636f6d300e0603551d0f0101ff0404030205a0301d0603551d250416301406082b0601050507030106082b0601050507030230750603551d1f046e306c3034a032a030862e687474703a2f2f63726c332e64696769636572742e636f6d2f736861322d65762d7365727665722d67312e63726c3034a032a030862e687474703a2f2f63726c342e64696769636572742e636f6d2f736861322d65762d7365727665722d67312e63726c30420603551d20043b3039303706096086480186fd6c0201302a302806082b06010505070201161c68747470733a2f2f7777772e64696769636572742e636f6d2f43505330818806082b06010505070101047c307a302406082b060105050730018618687474703a2f2f6f6373702e64696769636572742e636f6d305206082b060105050730028646687474703a2f2f636163657274732e64696769636572742e636f6d2f446967694365727453484132457874656e64656456616c69646174696f6e53657276657243412e637274300c0603551d130101ff04023000",
"github.com");
//equal(ASN1HEX.dump(tbsc.getEncodedHex()), "moge", "moge");
});

test("Certificate test", function() {
var cert = new KJUR.asn1.x509.Certificate(githubPARAM);
equal(cert.getEncodedHex(),githubHex,"github.com Hex");
equal(cert.getPEM().replace(/\s+/g,''), githubPEM.replace(/\s+/g,''), "github.com PEM");
//equal(ASN1HEX.dump(tbsc.getEncodedHex()), "Moge", "moge");
});

test("Certificate test 2", function() {
var cert = new KJUR.asn1.x509.Certificate(z6PARAM);
equal(cert.getEncodedHex(),z6CertHex,"z6.jsrsa Hex");
equal(cert.getPEM().replace(/\s+/g,''), z6CertPEM.replace(/\s+/g,''), "z6.jsrsa PEM");
//equal(ASN1HEX.dump(cert.getEncodedHex()), "Moge", "moge");
});

/*
test("Certificate test 3", function() {
z6PARAM.sigalg = "SHA512withRSAandMGF1";
var cert = new KJUR.asn1.x509.Certificate(z6PARAM);
equal(cert.getEncodedHex(),"hoge","z6 Hex");
//equal(cert.getPEM().replace(/\s+/g,''), githubPEM.replace(/\s+/g,''), "github.com PEM");
equal(ASN1HEX.dump(cert.getEncodedHex()), "Moge", "moge");
});
 */

test("Extensions class test", function() {
var _Extensions = KJUR.asn1.x509.Extensions;
var _dump = ASN1HEX.dump;
var aIn, dIn, hExpect;

aIn = [{
extname:"subjectAltName",
array:[{dns:"example.com"}]
}];
hExpect = "301830160603551d11040f300d820b6578616d706c652e636f6d";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "san hex");
equal(
ASN1HEX.dump(dIn.tohex()), 
ASN1HEX.dump(hExpect),
"san dump");

aIn = [{
  extname:"subjectAltName",
  array:[{dns:"example.com"}]
},{
  extname:"1.2.3.4",
  extn:{prnstr:'a'}
}];
hExpect = "302430160603551d11040f300d820b6578616d706c652e636f6d300a06032a03040403130161";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "san prv hex");
equal(
ASN1HEX.dump(dIn.tohex()), 
ASN1HEX.dump(hExpect),
"san prv dump");

aIn = [{
  extname: "nameConstraints",
  critical: true,
  permit: [{dns: "a.com"}]
}];
hExpect = "301930170603551d1e0101ff040d300ba00930078205612e636f6d";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "nameConstraints hex");

aIn = [{
  extname: "policyMappings",
  critical: true,
  array: [["0.1.2", "1.2.3"]]
}];
hExpect = "301830160603551d210101ff040c300a30080602010206022a03";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "policyMappings 0.1.2>1.2.3");
equal(_dump(dIn.tohex()), _dump(hExpect), "policyMappings 0.1.2>1.2.3 dump");

aIn = [{
  extname: "policyConstraints",
  critical: true,
  reqexp: 3
}];
hExpect = "3011300f0603551d240101ff04053003800103";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "policyConstraints reqexp=3");
equal(_dump(dIn.tohex()), _dump(hExpect), "policyConstraints reqexp=3 dump");

aIn = [{
  extname: "inhibitAnyPolicy",
  critical: true,
  skip: 3
}];
hExpect = "300f300d0603551d360101ff0403020103";
dIn = new _Extensions(aIn);
equal(dIn.tohex(), hExpect, "inhibitAnyPolicy skip=3");
equal(_dump(dIn.tohex()), _dump(hExpect), "inhibitAnyPolicy skip=3 dump");

});

});
-->
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-x509-ext.html">x509-ext</a> |
<a href="qunit-do-x509-hex2dn.html">x509-hex2dn</a> |
<a href="qunit-do-asn1x509.html">asn1x509</a> |
<a href="qunit-do-asn1x509-newcrt.html">asn1x509-newcrt</a> |
<a href="qunit-do-asn1x509-multirdn.html">asn1x509-multirdn</a> |
<a href="qunit-do-asn1csr.html">asn1csr</a> |
</body>
</html>
